

package cn.shengchao.examstar.distribute.infrastrure.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.shengchao.examstar.distribute.infrastrure.po.DistributeNodeInfo;
import cn.shengchao.examstar.distribute.infrastrure.query.DistributeAmountQuery;
import cn.shengchao.examstar.distribute.infrastrure.query.DistributeUserSaleDetailQuery;
import cn.shengchao.examstar.distribute.infrastrure.query.SaleAmountQuery;
import cn.shengchao.examstar.distribute.infrastrure.vo.DistributeContentUserGroup;
import cn.shengchao.examstar.rpc.uddsys.req.PlatformDistributeUserStatisticQuery;
import cn.shengchao.examstar.rpc.uddsys.resp.DistributeUserMonthStaticVo;
import cn.shengchao.examstar.rpc.uddsys.resp.DistributeUserProfitDetailVo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.shengchao.examstar.distribute.infrastrure.po.DistributeOrderTaskContent;
import cn.shengchao.examstar.distribute.infrastrure.mapper.DistributeOrderTaskContentMapper;
import cn.shengchao.examstar.distribute.infrastrure.service.DistributeOrderTaskContentService;

import java.util.List;

@Service
public class DistributeOrderTaskContentServiceImpl extends ServiceImpl<DistributeOrderTaskContentMapper, DistributeOrderTaskContent> implements DistributeOrderTaskContentService {
    @Override
    public List<DistributeUserProfitDetailVo> getDistributeUserProfitDetailList(DistributeUserSaleDetailQuery distributeUserSaleDetailQuery){
        return baseMapper.getDistributeUserProfitDetailList(distributeUserSaleDetailQuery);
    }

    /**
     * 获取一堆用户销售金额
     */
    @Override
    public List<DistributeContentUserGroup> getContentAmountGroupForUsers(SaleAmountQuery saleAmountQuery) {
        List<DistributeContentUserGroup> distributeSales = baseMapper.getDistributeUserGroupContentAmount(saleAmountQuery);
        if (CollUtil.isNotEmpty(distributeSales)){
            for (DistributeContentUserGroup distributeSale : distributeSales){
                if (distributeSale.getCourseSum() == null) {
                    distributeSale.setCourseSum(0L);
                }
            }
        }
        return distributeSales;
    }

    @Override
    public List<DistributeUserMonthStaticVo> listStaticListSortForUpLevelUser(PlatformDistributeUserStatisticQuery saleAmountQuery) {
        return List.of();
    }

    @Override
    public List<DistributeUserProfitDetailVo> getDistributeEmployeeContributeDetailList(DistributeUserSaleDetailQuery distributeUserSaleDetailQuery) {
        return baseMapper.getDistributeEmployeeContributeDetailList(distributeUserSaleDetailQuery);
    }

    @Override
    public DistributeContentUserGroup getContentAmountForDistributeUser(DistributeAmountQuery saleAmountQuery) {
        return baseMapper.getContentAmountForDistributeUser(saleAmountQuery);
    }

    @Override
    public List<DistributeNodeInfo> selectCourseDistributeNodeInfoListByOrderId(Long orderId) {
        return baseMapper.selectCourseDistributeNodeInfoListByOrderId(orderId);
    }

    @Override
    public List<DistributeNodeInfo> selectProductThirdDistributeNodeInfoListByOrderId(Long orderId) {
        return baseMapper.selectProductThirdDistributeNodeInfoListByOrderId(orderId);
    }
}
